package com.accp.reporter.service.impl;
import com.accp.reporter.pojo.User;
import com.accp.reporter.repository.UserRepository;
import com.accp.reporter.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserRepository userRepository;

    @Override
    public List<User> finAll() {
        return userRepository.finAll();
    }

    @Override
    public User userLogin(String userName, String password) {
        User user = userRepository.findByUsername(userName);
        if (user != null ) {
            if (user.getPassword().equals(password)) {
                return user;
            }
        }
        return null;
    }

    @Override
    public int addUser(User user) {
        return userRepository.addUser(user);
    }

    @Override
    public User finduserName(String userName) {
        return userRepository.finduserName(userName);
    }


}
